<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function arr(s, words) {
      let cnt = 0
      for (const word of words) {
        let i = 0, j = 0
        while (i < s.length && j < word.length) {
          if (s[i] === word[j]) {
            j++
          }
          i++
        }
        if (j === word.length) cnt++
      }
      return cnt
    };
    console.log(arr(s = "abcde", words = ["a", "bb", "acd", "ace"]));
  </script>
</body>

</html>